﻿using GN.Pay.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GN.Pay.Core.Values;
using System.Threading.Tasks;
using GN.Pay.Core.Entities;

namespace GN.Pay.GatewayWeb.JumpNotify
{
    /// <summary>
    /// 跳转通知服务
    /// </summary>
    public class HubPayNotifyService : IPayNotifyService
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="payNotifyData">通知数据</param>
        public async Task NotifySuccess(TradeNotify tradeNotify)
        {
            var notify = tradeNotify.GetPayNotifyData();
            if (notify != null && notify.ApplyId != null)
            {
                var session = HubSessionManager.GetApplySession(notify.ApplyId);
                if (session != null)
                {
                    await session.NotifySuccess(tradeNotify);
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="payNotifyData">通知数据</param>
        public async Task PaySuccess(TradeNotify tradeNotify)
        {
            var notify = tradeNotify.GetPayNotifyData();
            if (notify != null && notify.ApplyId != null)
            {
                var session = HubSessionManager.GetApplySession(notify.ApplyId);
                if (session != null)
                {
                    await session.PaySuccess(tradeNotify);
                }
            }
        }
    }
}